#!/bin/sh
set -e

pkg=vim
variant=basic
mandir=@MEMO_PREFIX@@MEMO_SUB_PREFIX@/share/man

# add /usr/bin/vim.variant as alternative for /usr/bin/vim. Priority are
# chosen accordingly to the principle: ``more features, higher priority''

if [ "$variant" != "tiny" ]; then
  update-alternatives --install @MEMO_PREFIX@@MEMO_SUB_PREFIX@/bin/vim vim @MEMO_PREFIX@@MEMO_SUB_PREFIX@/bin/vim.$variant 30
  update-alternatives --install @MEMO_PREFIX@@MEMO_SUB_PREFIX@/bin/vimdiff vimdiff @MEMO_PREFIX@@MEMO_SUB_PREFIX@/bin/vim.$variant 30
  update-alternatives --install @MEMO_PREFIX@@MEMO_SUB_PREFIX@/bin/rvim rvim @MEMO_PREFIX@@MEMO_SUB_PREFIX@/bin/vim.$variant 30
fi
update-alternatives --install @MEMO_PREFIX@@MEMO_SUB_PREFIX@/bin/rview rview @MEMO_PREFIX@@MEMO_SUB_PREFIX@/bin/vim.$variant 30
# Since other packages provide these commands, we'll setup alternatives for
# their manpages, too.
for i in vi view ex editor ; do
  update-alternatives \
    --install @MEMO_PREFIX@@MEMO_SUB_PREFIX@/bin/$i $i @MEMO_PREFIX@@MEMO_SUB_PREFIX@/bin/vim.$variant 30 \
    --slave $mandir/da/man1/$i.1@MEMO_MANPAGE_SUFFIX@ $i.da.1@MEMO_MANPAGE_SUFFIX@ $mandir/da/man1/vim.1@MEMO_MANPAGE_SUFFIX@ \
    --slave $mandir/de/man1/$i.1@MEMO_MANPAGE_SUFFIX@ $i.de.1@MEMO_MANPAGE_SUFFIX@ $mandir/de/man1/vim.1@MEMO_MANPAGE_SUFFIX@ \
    --slave $mandir/fr/man1/$i.1@MEMO_MANPAGE_SUFFIX@ $i.fr.1@MEMO_MANPAGE_SUFFIX@ $mandir/fr/man1/vim.1@MEMO_MANPAGE_SUFFIX@ \
    --slave $mandir/it/man1/$i.1@MEMO_MANPAGE_SUFFIX@ $i.it.1@MEMO_MANPAGE_SUFFIX@ $mandir/it/man1/vim.1@MEMO_MANPAGE_SUFFIX@ \
    --slave $mandir/ja/man1/$i.1@MEMO_MANPAGE_SUFFIX@ $i.ja.1@MEMO_MANPAGE_SUFFIX@ $mandir/ja/man1/vim.1@MEMO_MANPAGE_SUFFIX@ \
    --slave $mandir/pl/man1/$i.1@MEMO_MANPAGE_SUFFIX@ $i.pl.1@MEMO_MANPAGE_SUFFIX@ $mandir/pl/man1/vim.1@MEMO_MANPAGE_SUFFIX@ \
    --slave $mandir/ru/man1/$i.1@MEMO_MANPAGE_SUFFIX@ $i.ru.1@MEMO_MANPAGE_SUFFIX@ $mandir/ru/man1/vim.1@MEMO_MANPAGE_SUFFIX@ \
    --slave $mandir/man1/$i.1@MEMO_MANPAGE_SUFFIX@ $i.1@MEMO_MANPAGE_SUFFIX@ \
            $mandir/man1/vim.1@MEMO_MANPAGE_SUFFIX@
done

exit 0
